﻿/************************************************************************************************************
* file    : DailyReportRepository.cs
* author  : RDSSH
* function: 
* history : created by RDSSH 2019/1/25 10:25:55
************************************************************************************************************/
using System;
using System.Collections.Generic;
using IStrong.EC.Abstractions.Interfaces;
using IStrong.EC.DAO.Abstractions.Interfaces;
using IStrong.EC.WebApi.Results.Entity.Daily;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace IStrong.EC.WebApi.Results.Repository
{
    /// <summary>
    /// 数据访问类
    /// </summary>
    public class DailyReportRepository : IService
    {
        /// <summary>
        /// 数据库操作组件
        /// </summary>
        private readonly IDbContext _db;

        /// <summary>
        /// 配置信息
        /// </summary>
        private readonly IConfiguration _configuration;

        /// <summary>
        /// 日志组件
        /// </summary>
        private readonly ILogger<DailyReportRepository> _logger;

        /// <summary>
        /// 注入服务
        /// </summary>
        /// <param name="db"></param>
        /// <param name="configuration"></param>
        /// <param name="logger"></param>
        public DailyReportRepository(IDbContext db, ILogger<DailyReportRepository> logger, IConfiguration configuration)
        {
            _db = db;
            _logger = logger;
            _configuration = configuration;
        }
        public IEnumerable<Dailyreports> GetDailyReport(object param)
        {
            return _db.Query<Dailyreports>("Dailyreports.s_dailyreports", param);
        }

        public int AddDailyReport(object param)
        {
            return _db.ExecuteScalar<int>("Dailyreports.i_dailyreports", param);
        }

        public int UpdateDailyReport(object param)
        {
            return _db.Execute("Dailyreports.u_dailyreports", param);
        }

        public int DeleteDailyReport(object param)
        {
            return _db.Execute("Dailyreports.d_dailyreports", param);
        }
    }
}
